import requests

def get_weather(city):
    # 定义API Key
    api_key = "90ef0ce3f53344ed628febf6ccfd51b6"
    # 定义API的基础URL
    base_url = "http://api.openweathermap.org/data/2.5/weather"
    # 定义API请求的参数
    params = {
        "q": city,  # 城市名称
        "appid": api_key,  # API Key
        "units": "metric"  # 温度单位为摄氏度
    }
    # 发送API请求
    response = requests.get(base_url, params=params)
    # 如果请求成功
    if response.status_code == 200:
        # 解析API响应的JSON数据
        data = response.json()
        # 获取天气描述
        weather = data["weather"][0]["description"]
        # 获取温度
        temperature = data["main"]["temp"]
        # 打印天气信息和温度
        print(f"Weather in {city}: {weather}, Temperature: {temperature}°C")
    else:
        # 如果请求失败，打印错误信息
        print("Error: Unable to retrieve weather data.")

# 获取用户输入的城市名称
city = input("Enter the city name: ")
# 调用函数获取天气信息
get_weather(city)